﻿Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Public Class ObjektKOBildAendernMenue
    Inherits ObjektFormMenue
    Const XOffSetFuerKOUndPanels = 350
    ''' <summary>
    ''' Die Armee deren KO's wir aendern moechten.
    ''' </summary>
    ''' <remarks></remarks>
    Public AusgewaehlteArmee As Integer = 0
    ''' <summary>
    ''' Der momentan ausgewaehlte KO
    ''' </summary>
    ''' <remarks></remarks>
    Dim MomentanerKO As Integer = 0
    ''' <summary>
    ''' Der KO der vielleicht der Naechste
    ''' </summary>
    ''' <remarks></remarks>
    Dim KO As Integer
    ''' <summary>
    ''' Normaler Text
    ''' </summary>
    ''' <remarks></remarks>
    Dim Text As ObjektText
    ''' <summary>
    ''' Kleiner Text
    ''' </summary>
    ''' <remarks></remarks>
    Dim KleinerText As ObjektText
    ''' <summary>
    ''' Texturen fuer die KO's
    ''' </summary>
    ''' <remarks></remarks>
    Dim KOAnzeigeTexturen() As Texture = {}
    ''' <summary>
    ''' Die KO's die wir malen muessen
    ''' </summary>
    ''' <remarks></remarks>
    Dim AnzahlderGemaltenKos As Integer = 0
    ''' <summary>
    ''' Die Position bei der KO Auswahl
    ''' </summary>
    ''' <remarks></remarks>
    Dim KOCursor As Point
    ''' <summary>
    ''' Hier fangen wir an zu malen
    ''' </summary>
    ''' <remarks></remarks>
    Dim KOOffset As Integer = 0
    ''' <summary>
    ''' Die KO Textur
    ''' </summary>
    ''' <remarks></remarks>
    Dim KOPics As New List(Of Texture)
    ''' <summary>
    ''' Der Name der Textur
    ''' </summary>
    ''' <remarks></remarks>
    Dim KOPicNames As New List(Of String)
    ''' <summary>
    ''' Das momentan ausgewaehlte Bild
    ''' </summary>
    ''' <remarks></remarks>
    Dim CurrentKOPic As Integer
    Public Overrides Sub ChangeWindowSize(ByVal PosChange As System.Drawing.Point)
        MyBase.ChangeWindowSizeObjekte(PosChange)
    End Sub
    Public Overrides Sub Frame()

    End Sub
    Public Overrides Sub SetMausBild()
        ObjektMaus.Zustand = ObjektMaus.Zustaende.Menue
    End Sub
    Public Overrides Sub SprachEingabe(ByVal Eingabe As String)

    End Sub
    Public Overrides Sub IniMenue()

    End Sub

    Public Sub New()
        MyBase.New(New ObjektButton() {}, Nothing, New ObjektNumericUpDown() {}, Nothing, New ObjektValueSchieber() {}, New ObjektMultiValue() {}, New ObjektCheckBox() {})
        If DataSettings.Verhaeltnis = Hauptmenue.Breitbild Then
            Objektverwalter.LoadHintergrund(DataSettings.Resourcenpfad + "Backgrounds\OptionenGross.png")
        Else
            Objektverwalter.LoadHintergrund(DataSettings.Resourcenpfad + "Backgrounds\Optionen.png")
        End If
        If ObjektKartenauswahlMenue.ArmeeBanner.Length = 0 Then
            For I1 = 0 To Objektverwalter.GetKOLength() - 1
                If Not Hauptmenue.User.LockedCOColors.Contains(Objektverwalter.GetKO(I1).KOID) Then
                    If Array.IndexOf(ObjektKartenauswahlMenue.Armeen, Objektverwalter.GetKO(I1).Armee) < 0 Then
                        Array.Resize(ObjektKartenauswahlMenue.ArmeeBanner, ObjektKartenauswahlMenue.ArmeeBanner.Length + 1)
                        Array.Resize(ObjektKartenauswahlMenue.Armeen, ObjektKartenauswahlMenue.ArmeeBanner.Length)
                        ObjektKartenauswahlMenue.ArmeeBanner(ObjektKartenauswahlMenue.ArmeeBanner.Length - 1) = Grafikengine.LoadTexture(DataSettings.Resourcenpfad + "Kartenauswahl\" + Objektverwalter.GetKO(I1).Armee + ".png")
                        ObjektKartenauswahlMenue.Armeen(ObjektKartenauswahlMenue.Armeen.Length - 1) = Objektverwalter.GetKO(I1).Armee
                    End If
                End If
            Next
        End If
        Text = New ObjektText(New String() {}, 0, 0, Nothing, Schriftengine.Schriftarten.Arial, 12, FontStyle.Regular)
        KleinerText = New ObjektText(New String() {}, 0, 0, Nothing, Schriftengine.Schriftarten.Arial_Unicode_MS, 8, FontStyle.Regular)
        Array.Resize(KOAnzeigeTexturen, 3)
        KOAnzeigeTexturen(0) = Grafikengine.LoadTexture(Image.FromFile(DataSettings.Resourcenpfad + "Kartenauswahl\KOAuswahl.png"), Hauptmenue.Farbtabelleerstellen(Hauptmenue.AlleFarbtabellen(0)))
        KOAnzeigeTexturen(1) = Grafikengine.LoadTexture(DataSettings.Resourcenpfad + "Kartenauswahl\KeinKO.png")
        KOAnzeigeTexturen(2) = Grafikengine.LoadTexture(Image.FromFile(DataSettings.Resourcenpfad + "Kartenauswahl\KOAnzeigeCursor.png"), Hauptmenue.Farbtabelleerstellen(Hauptmenue.AlleFarbtabellen(0)))
        ArmeeFestlegen(0)
        Dim KO As Integer = 0
        While Hauptmenue.User.LockedCOColors.Contains(Objektverwalter.GetKO(KO).KOID)
            KO += 1
        End While
        ChangeCurrentCO(KO)
        NeuButton(20, DataSettings.BildschirmHoehe - 30, DataSettings.Resourcenpfad + "Objects\Button.png", "Zurueck", New PointF, , , , )
        NeuButton(150, DataSettings.BildschirmHoehe - 30, DataSettings.Resourcenpfad + "Objects\Button.png", "Speichern", New PointF, , , , )
        NeuButton(DataSettings.BildschirmBreite - 320, DataSettings.BildschirmHoehe - 30, DataSettings.Resourcenpfad + "Objects\Button.png", "Links", New PointF, , , , )
        NeuButton(DataSettings.BildschirmBreite - 170, DataSettings.BildschirmHoehe - 30, DataSettings.Resourcenpfad + "Objects\Button.png", "Rechts", New PointF, , , , )

    End Sub

    Public Overrides Sub KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)

    End Sub

    Public Overrides Sub Malen()
        'KO Auswahl malen
        DrawKOPics()
        Dim sngRotation As Double = 0
        Dim intColor As Color = Color.FromArgb(255, 255, 255, 255)
        Grafikengine.recBild = Nothing
        Grafikengine.ptfRotCenter = Nothing
        Grafikengine.szfScale = Nothing
        Grafikengine.ptfPosition = New Drawing.Point(10, 0)
        For I = 0 To ObjektKartenauswahlMenue.ArmeeBanner.Length - 1
            If I = AusgewaehlteArmee Then
                Grafikengine.recBild = Nothing
            Else
                With Grafikengine.recBild
                    .Y = 11
                    .Width = 20
                    .Height = 42
                End With
            End If
            Grafikengine.Sprite.Draw2D(ObjektKartenauswahlMenue.ArmeeBanner(I), Grafikengine.recBild, Grafikengine.szfScale, Grafikengine.ptfRotCenter, sngRotation, Grafikengine.ptfPosition, intColor)
            Grafikengine.ptfPosition.X += 19
        Next
        Grafikengine.recBild = Nothing
        Grafikengine.ptfPosition = New Drawing.Point(0, 53)
        Grafikengine.Sprite.Draw2D(KOAnzeigeTexturen(0), Grafikengine.recBild, Grafikengine.szfScale, Grafikengine.ptfRotCenter, sngRotation, Grafikengine.ptfPosition, intColor)
        Grafikengine.ptfPosition.X += 2
        Grafikengine.ptfPosition.Y += 9
        Grafikengine.Sprite.Draw2D(KOAnzeigeTexturen(1), Grafikengine.recBild, Grafikengine.szfScale, Grafikengine.ptfRotCenter, sngRotation, Grafikengine.ptfPosition, intColor)
        intColor = Color.FromArgb(180, 255, 255, 255)

        Dim Start As Boolean = True
        Grafikengine.ptfPosition = New Drawing.Point(0, 10)
        Dim StartzahlderKOs As Integer = ObjektKartenauswahlMenue.IndexOfArmee(ObjektKartenauswahlMenue.Armeen(AusgewaehlteArmee))
        Dim I2 As Integer = StartzahlderKOs
        While I2 < Objektverwalter.GetKOLength()
            If Objektverwalter.GetKO(I2).Armee = ObjektKartenauswahlMenue.Armeen(AusgewaehlteArmee) Then
                Grafikengine.ptfPosition.X = 2
                Grafikengine.ptfPosition.Y += 52
                Dim Ende As Integer = 2
                If Start Then
                    Grafikengine.ptfPosition.X += 52
                    Ende = 1
                    Start = False
                End If
                For I = 0 To Ende
                    If I2 < Objektverwalter.GetKOLength() Then
                        If Not Hauptmenue.User.LockedCOColors.Contains(Objektverwalter.GetKO(I2).KOID) Then
                            Grafikengine.Sprite.Draw2D(KOAnzeigeTexturen(2), Grafikengine.recBild, Grafikengine.szfScale, Grafikengine.ptfRotCenter, sngRotation, Grafikengine.ptfPosition, intColor)
                            Grafikengine.ptfPosition.X += 52
                        Else
                            I -= 1
                        End If
                        I2 += 1
                    Else
                        Grafikengine.Sprite.Draw2D(KOAnzeigeTexturen(2), Grafikengine.recBild, Grafikengine.szfScale, Grafikengine.ptfRotCenter, sngRotation, Grafikengine.ptfPosition, intColor)
                        Grafikengine.ptfPosition.X += 52
                    End If
                Next
            Else
                Exit While
            End If
        End While
        intColor = Color.FromArgb(255, 255, 255, 255)
        I2 = StartzahlderKOs
        Start = True
        Grafikengine.ptfPosition = New Drawing.Point(0, 10)
        While I2 < Objektverwalter.GetKOLength()
            Grafikengine.ptfPosition.X = 2
            Grafikengine.ptfPosition.Y += 52
            Dim Ende As Integer = 2
            If Start Then
                Grafikengine.ptfPosition.X += 52
                Ende = 1
                Start = False
            End If
            For I = 0 To Ende
                If Objektverwalter.GetKO(I2).Armee = ObjektKartenauswahlMenue.Armeen(AusgewaehlteArmee) Then
                    If Not Hauptmenue.User.LockedCOColors.Contains(Objektverwalter.GetKO(I2).KOID) Then
                        Objektverwalter.GetKO(I2).KOGesichtsausdruckMalen(0, Grafikengine.ptfPosition.X, Grafikengine.ptfPosition.Y)
                        Grafikengine.ptfPosition.X += 52
                    Else
                        I -= 1
                    End If
                    I2 += 1
                Else
                    Exit While
                End If
                If I2 >= Objektverwalter.GetKOLength() Then Exit While
            Next
        End While
        Grafikengine.recBild = Nothing
        Grafikengine.ptfPosition = KOCursor
        Grafikengine.Sprite.Draw2D(KOAnzeigeTexturen(2), Grafikengine.recBild, Grafikengine.szfScale, Grafikengine.ptfRotCenter, sngRotation, Grafikengine.ptfPosition, intColor)

        If MomentanerKO >= 0 Then
            Objektverwalter.GetKO(MomentanerKO).MiniGesichtMalen(167, 212, False)
            Text.neuerText(New String() {Objektverwalter.GetKO(MomentanerKO).KOBeschreibung.Name}, 34, -3, Nothing, , 0)
            Text.Malen(Grafikengine.ptfPosition)
            Grafikengine.Sprite.Transform = Matrix.Identity
            Dim X As Integer = Text.GetSchriftart.MeasureString(Grafikengine.Sprite, Objektverwalter.GetKO(MomentanerKO).KOBeschreibung.Name, DrawTextFormat.None, Color.Black).Width / 2
            Text.neuerText(New String() {Objektverwalter.GetKO(MomentanerKO).KOBeschreibung.Name}, 165 + 178 / 2 - X, 70, Nothing)
            Text.Malen(New Point)
            If Objektverwalter.GetKO(MomentanerKO).KOBeschreibung.Stil.Length > 0 Then
                KleinerText.neuerText(Objektverwalter.GetKO(MomentanerKO).KOBeschreibung.Stil, 165, 90, Nothing)
                KleinerText.Malen(New Point)
            End If
        End If
        If KOCursor.Y > 0 And KO >= 0 Then
            Grafikengine.ptfPosition = New Point()
            If KO >= 0 Then
                Objektverwalter.GetKO(KO).KOMalen(XOffSetFuerKOUndPanels, 55)
            End If
        End If


        MyBase.ObjekteMalen()
    End Sub
    Private Sub DrawKOPics()
        Dim OffSet As New Point
        Dim KONumbers As New Size
        KONumbers.Width = Math.DivRem(DataSettings.BildschirmBreite - XOffSetFuerKOUndPanels, 220, OffSet.X)
        KONumbers.Height = Math.DivRem(DataSettings.BildschirmHoehe - 40, 360, OffSet.Y)
        OffSet.X += XOffSetFuerKOUndPanels
        For Y = 0 To KONumbers.Height - 1
            For X = 0 To KONumbers.Width - 1
                Dim Pos As Integer = KOOffset + X + Y * KONumbers.Width
                If Pos < KOPics.Count Then
                    If Pos = CurrentKOPic Then
                        Grafikengine.fillRect(New Rectangle(OffSet.X + X * 220 - 1, OffSet.Y + Y * 360 - 1, 1, 352), Color.Green)
                        Grafikengine.fillRect(New Rectangle(OffSet.X + X * 220 - 1, OffSet.Y + Y * 360 - 1, 213, 1), Color.Green)
                        Grafikengine.fillRect(New Rectangle(OffSet.X + X * 220 - 1, OffSet.Y + Y * 360 + 350, 213, 1), Color.Green)
                        Grafikengine.fillRect(New Rectangle(OffSet.X + X * 220 + 211, OffSet.Y + Y * 360 - 1, 1, 352), Color.Green)
                    Else
                        Grafikengine.fillRect(New Rectangle(OffSet.X + X * 220 - 1, OffSet.Y + Y * 360 - 1, 1, 352), Color.Red)
                        Grafikengine.fillRect(New Rectangle(OffSet.X + X * 220 - 1, OffSet.Y + Y * 360 - 1, 213, 1), Color.Red)
                        Grafikengine.fillRect(New Rectangle(OffSet.X + X * 220 - 1, OffSet.Y + Y * 360 + 350, 213, 1), Color.Red)
                        Grafikengine.fillRect(New Rectangle(OffSet.X + X * 220 + 211, OffSet.Y + Y * 360 - 1, 1, 352), Color.Red)
                    End If

                    Objektverwalter.KO.KOMalen(OffSet.X + X * 220, OffSet.Y + Y * 360, KOPics(Pos))
                End If
            Next
        Next
    End Sub
    Public Sub MoveKOStart(ByVal Direction As Integer)
        Dim KONumbers As New Size
        KONumbers.Width = Math.DivRem(DataSettings.BildschirmBreite - XOffSetFuerKOUndPanels, 220, 0)
        KONumbers.Height = Math.DivRem(DataSettings.BildschirmHoehe - 40, 360, 0)
        If Direction > 0 Then
            KOOffset += KONumbers.Width * KONumbers.Height
            If KOOffset >= KOPics.Count Then KOOffset = KOPics.Count - KONumbers.Width * KONumbers.Height
            If KOOffset < 0 Then KOOffset = 0
        Else
            KOOffset -= KONumbers.Width * KONumbers.Height
            If KOOffset < 0 Then KOOffset = 0
        End If
    End Sub

    Public Overrides Sub MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        checkMouseDownObjekte(ObjektMaus.XKoordinate, ObjektMaus.YKoordinate)
    End Sub

    Public Overrides Sub MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        GetKOCursorPosition(e.X, e.Y, False)
        MouseMoveObjekte(e.X, e.Y)
    End Sub

    Public Overrides Sub MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        CheckArmeeKlick(e.X, e.Y)
        CurrentKOPic = GetNewKOPic(e.X, e.Y)
        GetKOCursorPosition(e.X, e.Y, True)
        Select Case e.Button
            Case Windows.Forms.MouseButtons.Left
                Dim Effekt As String = checkMouseUPObjekte(ObjektMaus.XKoordinate, ObjektMaus.YKoordinate)
                Select Case Effekt.ToLower
                    Case "zurueck"
                        Hauptmenue.Ini(Hauptmenue.Formmodi.Optionen)
                    Case "speichern"
                        Dim Name As String = Objektverwalter.GetKO(MomentanerKO).KOID + ";" + KOPicNames(CurrentKOPic)
                        Dim Add As Boolean = False
                        Dim Pictures() As String = DataSettings.KOTexturen.Split("|")
                        For I = 0 To Pictures.Length - 1
                            If Pictures(I).ToLower.StartsWith(Objektverwalter.GetKO(MomentanerKO).KOID.ToLower) Then
                                If KOPicNames(CurrentKOPic).ToLower = Objektverwalter.GetKO(MomentanerKO).KOID.ToLower Then
                                    Pictures(I) = ""
                                Else
                                    Pictures(I) = Name
                                End If
                                Exit For
                            ElseIf I = Pictures.Length - 1 Then
                                Add = True
                            End If
                        Next
                        If Add Then
                            If DataSettings.KOTexturen = "" Then
                                DataSettings.KOTexturen += Name
                            Else
                                DataSettings.KOTexturen += "|" + Name
                            End If
                        Else
                            DataSettings.KOTexturen = ""
                            For I = 0 To Pictures.Length - 1
                                If Pictures(I) <> "" Then
                                    If I = 0 Then
                                        DataSettings.KOTexturen += Pictures(I)
                                    Else
                                        DataSettings.KOTexturen += "|" + Pictures(I)
                                    End If
                                End If
                            Next
                        End If
                        DataSettings.MySettingsIniSave()
                        Objektverwalter.SetKOTexture(KOPics(CurrentKOPic), MomentanerKO)
                    Case "links"
                        MoveKOStart(-1)
                    Case "rechts"
                        MoveKOStart(1)
                End Select
        End Select

    End Sub

    Public Overrides Sub MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)

    End Sub

    ''' <summary>
    ''' Wir schauen nach, von welchem KO wir die Informationen anzeigen muessen
    ''' </summary>
    ''' <param name="X"></param>
    ''' <param name="Y"></param>
    ''' <remarks></remarks>
    Private Sub GetKOCursorPosition(ByVal X As Integer, ByVal Y As Integer, ByVal Click As Boolean)
        Dim Startrechteck As New Rectangle(2, 62, 48, 48)
        Dim I2 As Integer = 0
        For I = 0 To AnzahlderGemaltenKos
            If Startrechteck.Contains(X, Y) Then
                If I = 0 Then
                    KO = -1
                Else
                    KO = I + ObjektKartenauswahlMenue.IndexOfArmee(ObjektKartenauswahlMenue.Armeen(AusgewaehlteArmee)) - 1
                    Dim Ende As Integer = KO
                    For I2 = ObjektKartenauswahlMenue.IndexOfArmee(ObjektKartenauswahlMenue.Armeen(AusgewaehlteArmee)) To Ende
                        If Hauptmenue.User.LockedCOColors.Contains(Objektverwalter.GetKO(I2).KOID) Then
                            KO += 1
                        End If
                    Next
                    While Hauptmenue.User.LockedCOColors.Contains(Objektverwalter.GetKO(KO).KOID)
                        KO += 1
                        If KO >= Objektverwalter.GetKOLength Then
                            KO = -1
                            Exit While
                        End If
                    End While
                End If
                If Click Then
                    If KO >= 0 Then
                        MomentanerKO = KO
                        ChangeCurrentCO(MomentanerKO)
                    End If
                End If
                KOCursor = New Point(Startrechteck.X, Startrechteck.Y)
                Exit For
            End If
            Startrechteck.X += 52
            I2 += 1
            If I2 > 2 Then
                I2 = 0
                Startrechteck.X = 2
                Startrechteck.Y += 52
            End If
            If I = AnzahlderGemaltenKos Then
                KOCursor = New Point(-50, -50)
            End If
        Next
    End Sub
    Private Sub ChangeCurrentCO(ByVal NewCO As Integer)
        MomentanerKO = NewCO
        KOPics.Clear()
        KOPicNames.Clear()
        KOOffset = 0
        CurrentKOPic = 0
        If MomentanerKO >= 0 Then

            Dim ID As String = Objektverwalter.GetKO(MomentanerKO).KOID
            Dim Army As String = Objektverwalter.GetKO(MomentanerKO).Armee
            For Each Pic In My.Computer.FileSystem.GetFiles(DataSettings.Resourcenpfad + "CO's\CO\" + Army + "\", FileIO.SearchOption.SearchTopLevelOnly, "*.png")
                Dim Name As String = Pic.Replace(DataSettings.Resourcenpfad + "CO's\CO\" + Army + "\", "").Replace(".png", "")
                If Name.ToLower.StartsWith(ID.ToLower) Then


                    Dim ColorTable As Bitmap = Objektverwalter.KO.GetColorTable(Name, Army)
                    If ColorTable IsNot Nothing Then
                        For Y = 0 To ColorTable.Height - 1
                            Dim Picture As Bitmap = Image.FromFile(Pic)
                            For X = 0 To ColorTable.Width - 1
                                Picture = Grafikengine.Pixelneueinfaerben(Picture, ColorTable.GetPixel(X, 0), ColorTable.GetPixel(X, Y))
                            Next
                            KOPics.Add(Grafikengine.LoadTexture(Picture))
                            KOPicNames.Add(Name.ToUpper + ":" + Y.ToString)
                            Picture.Dispose()
                        Next
                        ColorTable.Dispose()
                    Else
                        KOPics.Add(Grafikengine.LoadTexture(Pic))
                        KOPicNames.Add(Name.ToUpper)
                    End If
                    If Name.ToUpper + ":0" = ID.ToUpper Or Name.ToUpper = ID.ToUpper Then
                        CurrentKOPic = KOPics.Count - 1
                    End If
                End If
            Next
            Dim KOPictureNames As String() = DataSettings.KOTexturen.Split("|")
            For Each Pic In KOPictureNames
                If Pic.ToLower.StartsWith(ID.ToLower) Then
                    Dim OldPicName As String = Pic.Split(";")(1).ToLower
                    For I = 0 To KOPicNames.Count - 1
                        If KOPicNames(I).ToLower = OldPicName Then
                            CurrentKOPic = I
                            Exit For
                        End If
                    Next
                    Exit For
                End If
            Next

        End If
    End Sub
    ''' <summary>
    ''' legt die Armee des Spielers fest
    ''' </summary>
    ''' <param name="Armee"></param>
    ''' <remarks></remarks>
    Private Sub ArmeeFestlegen(ByVal Armee As Integer)
        AusgewaehlteArmee = Armee
        AnzahlderGemaltenKos = ObjektKartenauswahlMenue.LastIndexOfArmee(ObjektKartenauswahlMenue.Armeen(AusgewaehlteArmee)) - ObjektKartenauswahlMenue.IndexOfArmee(ObjektKartenauswahlMenue.Armeen(AusgewaehlteArmee)) + 1
        Dim Ende As Integer = AnzahlderGemaltenKos
        For I = ObjektKartenauswahlMenue.IndexOfArmee(ObjektKartenauswahlMenue.Armeen(AusgewaehlteArmee)) To Ende
            If Hauptmenue.User.LockedCOColors.Contains(Objektverwalter.GetKO(I).KOID) Then
                AnzahlderGemaltenKos -= 1
            End If
        Next
    End Sub
    ''' <summary>
    ''' Wir schauen ob wir die KO'S einer anderen Armee anzeigen muessen.
    ''' </summary>
    ''' <param name="X"></param>
    ''' <param name="Y"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function CheckArmeeKlick(ByVal X As Integer, ByVal Y As Integer) As Boolean
        Dim Rechteck As New Rectangle(10, 0, 19 * ObjektKartenauswahlMenue.ArmeeBanner.Length, 42)
        If Rechteck.Contains(X, Y) Then
            ArmeeFestlegen(Math.DivRem(X - Rechteck.X, 19, 0))
            Return True
        End If
        Return False
    End Function

    Private Function GetNewKOPic(ByVal X1 As Integer, ByVal Y1 As Integer) As Integer
        Dim OffSet As New Point
        Dim KONumbers As New Size
        KONumbers.Width = Math.DivRem(DataSettings.BildschirmBreite - XOffSetFuerKOUndPanels, 220, OffSet.X)
        KONumbers.Height = Math.DivRem(DataSettings.BildschirmHoehe - 40, 360, OffSet.Y)
        OffSet.X += XOffSetFuerKOUndPanels
        For Y = 0 To KONumbers.Height - 1
            For X = 0 To KONumbers.Width - 1
                Dim Pos As Integer = KOOffset + X + Y * KONumbers.Width
                If Pos < KOPics.Count Then
                    Dim R As New Rectangle(OffSet.X + X * 220, OffSet.Y + Y * 360, 211, 350)
                    If R.Contains(X1, Y1) Then
                        Return Pos
                    End If
                End If
            Next
        Next
        Return CurrentKOPic
    End Function

    Public Overrides Sub KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)

    End Sub

    Public Overrides Sub Reset()
        MyBase.Reset()
        ReDim ObjektKartenauswahlMenue.ArmeeBanner(-1)
        ReDim ObjektKartenauswahlMenue.Armeen(-1)
    End Sub
End Class
